from selenium.webdriver.common.by import By

from page_objects.base_page import BasePage


class CategoryCreatePage(BasePage):
    __INPUT_UID = (By.XPATH, '//label[text()="商品编号"]/../div//input')
    __INPUT_NAME = (By.XPATH, '//label[text()="商品名称"]/../div//input')
    _PUT = (By.XPATH,'//*[text()="上架"]')
    def create_category(self, uid, name):
        """创建商品页面：创建商品"""
        # 输入“商品名称”
        self.do_send_keys(uid,self.__INPUT_UID)
        self.do_send_keys(name,self.__INPUT_NAME)
        # 点击“确定”按钮
        self.do_find(self._PUT).click()
        # ==》商品列表页面
        from page_objects.category_list_page import CategoryListPage
        return CategoryListPage(self.driver)
